package com.lanxin.hr.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lanxin.hr.entity.ZzDepartmentJob;
import com.lanxin.hr.entity.ZzEmployee;
import com.lanxin.hr.mapper.DepartmentJobVoMapper;
import com.lanxin.hr.mapper.ZzDepartmentJobMapper;
import com.lanxin.hr.mapper.ZzEmployeeMapper;
import com.lanxin.hr.service.IZzDepartmentJobService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lanxin.hr.vo.DepartmentJobVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2025-07-22
 */
@Service
public class ZzDepartmentJobServiceImpl extends ServiceImpl<ZzDepartmentJobMapper, ZzDepartmentJob> implements IZzDepartmentJobService {

    @Autowired
    private DepartmentJobVoMapper departmentJobVoMapper;

    @Autowired
    private ZzDepartmentJobMapper departmentJobMapper;

    @Autowired
    private ZzEmployeeMapper employeeMapper;

    //联合查询每个部门下属的职位
    @Override
    public List<DepartmentJobVo> selectDepartmentJobByDId(String dId) {
        return departmentJobVoMapper.selectDepartmentJobVoByDId(dId);
    }

    //删除部门对应的职位
    @Override
    public int deleteDepartmentJobByDId(Integer deptId) {
        QueryWrapper<ZzDepartmentJob> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("deptid",deptId);
        return departmentJobMapper.delete(queryWrapper);
    }


    //添加部门中的职位
    @Override
    public int addDeptJob(ZzDepartmentJob departmentJob) {
        return departmentJobMapper.insert(departmentJob);
    }

}
